package com.xand.bt.terminal.ui.ticker;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.xand.bt.terminal.ui.UIConst;

public class MarketTickerDisplay {

	private JPanel jPanel;
	
	private JPanel dateLabelPanel;
	private JLabel dateLabel;
	private JLabel dateValue;
	
	private JPanel lowLabelPanel;
	private JLabel lowLabel;
	private JLabel lowValue;
	
	private JPanel highLabelPanel;
	private JLabel highLabel;
	private JLabel highValue;
	
	private JPanel lastPriceLabelPanel;
	private JLabel lastPriceLabel;
	private JLabel lastPriceValue;
	
	private JPanel volumeLabelPanel;
	private JLabel volumeLabel;
	private JLabel volumeValue;
	
	public MarketTickerDisplay() {
		this.jPanel = new JPanel();
		
		BoxLayout layout = new BoxLayout(this.jPanel, BoxLayout.Y_AXIS);
		
		this.jPanel.setLayout(layout);
		this.jPanel.setBorder(UIConst.MARKET_TICKER_BORDER);
		this.jPanel.setPreferredSize(new Dimension(470, 362));
		
		this.createDatePanel();
		this.createHighPanel();
		this.createLastPricePanel();
		this.createLowPanel();
		this.createVolumePanel();
		
		this.jPanel.add(this.dateLabelPanel);
		this.jPanel.add(this.lowLabelPanel);
		this.jPanel.add(this.highLabelPanel);
		this.jPanel.add(this.lastPriceLabelPanel);
		this.jPanel.add(this.volumeLabelPanel);
	}
	
	public JPanel getPanel() {
		return this.jPanel;
	}
	
	private void createDatePanel() {
		this.dateLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		this.dateLabelPanel.setBorder(UIConst.THIN_BLACK_BORDER);
		
		this.dateLabel = new JLabel("Date: ");
		this.dateLabel.setSize(new Dimension(50, 10));
		this.dateValue = new JLabel("14/08/12");
		this.dateValue.setSize(new Dimension(50, 10));
		
		this.dateLabelPanel.add(this.dateLabel);
		this.dateLabelPanel.add(this.dateValue);
		this.dateLabelPanel.setSize(new Dimension(100, 10));
	}
	
	private void createLowPanel() {
		this.lowLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		this.lowLabelPanel.setBorder(UIConst.THIN_BLACK_BORDER);
		
		this.lowLabel = new JLabel("Low: ");
		this.lowValue = new JLabel("11,376 USD");
		
		this.lowLabelPanel.add(this.lowLabel);
		this.lowLabelPanel.add(this.lowValue);
	}
	
	private void createHighPanel() {
		this.highLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		this.highLabelPanel.setBorder(UIConst.THIN_BLACK_BORDER);
		
		this.highLabel = new JLabel("High: ");
		this.highValue = new JLabel("11,558 USD");
		
		this.highLabelPanel.add(this.highLabel);
		this.highLabelPanel.add(this.highValue);
	}
	
	private void createLastPricePanel() {
		this.lastPriceLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		this.lastPriceLabelPanel.setBorder(UIConst.THIN_BLACK_BORDER);
		
		this.lastPriceLabel = new JLabel("Last Price: ");
		this.lastPriceValue = new JLabel("11,400 USD");
		
		this.lastPriceLabelPanel.add(this.lastPriceLabel);
		this.lastPriceLabelPanel.add(this.lastPriceValue);
	}
	
	private void createVolumePanel() {
		this.volumeLabelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
		this.volumeLabelPanel.setBorder(UIConst.THIN_BLACK_BORDER);
		
		this.volumeLabel = new JLabel("Volume: ");
		this.volumeValue = new JLabel("1251,96 USD / 108,752 BTC");
		
		this.volumeLabelPanel.add(this.volumeLabel);
		this.volumeLabelPanel.add(this.volumeValue);
	}
	
}
